Skip to content

refactor(integrations): generate the flush acknowledgement helpers from one source - #2645

Merged
hidb4ai merged 1 commit into
oceanbase:masterfrom
Fengzdadi:refactor/ts-lifecycle-flush
Nov 16, 2026
Merged

hidb4ai merged 1 commit into
oceanbase:masterfrom
Fengzdadi:refactor/ts-lifecycle-flush

Conversation

@Fengzdadi

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

Part of #2250. Follows #2623, which made integrations/lifecycle/ the source of the TypeScript helpers that host plugins ship, and #2180, which aligned the OpenClaw and Pi flush acknowledgement.

Rationale for this change

#2180 gave OpenClaw and Pi the same flush acknowledgement, checked by the shared cases in tests/integration_conformance/cases.json. Each plugin still keeps its own copy of the three helpers behind it:

  • nonNegativeInteger;
  • the flush response check (flushProgress);
  • scopeCorrelation, the hashed Scope label in diagnostics.

Nothing keeps the copies in step. This PR generates them from one source, as #2623 did for the transport.

Before the move the copies were compared:

  • The validation, the returned progress, and the correlation hash are identical.
  • The only difference is the error thrown for an invalid flush response. OpenClaw throws a plain Error("PowerContext returned an invalid flush payload"). Pi throws its own InvalidResponseError('/v1/memory/flush'). This PR keeps both.

What changes are included in this PR?

Source and copies

  • New integrations/lifecycle/flush-progress.ts exports FlushProgress, nonNegativeInteger, readFlushProgress, and scopeCorrelation.
    • readFlushProgress applies the same checks as before.
    • It returns undefined for a response that is not a flush result, so the module needs nothing beyond Node.js built-ins and no plugin's error type.
  • scripts/generate_integration_lifecycle.py writes it to src/flush-progress.ts in the OpenClaw and Pi plugins. make check and tests/test_integration_lifecycle.py reject a copy that drifts. The name avoids Pi's existing src/flush.ts, which the generator's check would otherwise reject.

Plugins

  • OpenClaw src/lifecycle.ts:
    • flushProgress calls readFlushProgress and throws the same Error as before;
    • sourcePosition uses the shared nonNegativeInteger;
    • the local FlushProgress type, nonNegativeInteger, scopeCorrelation, and the node:crypto import are removed;
    • no other part of the file changes.
  • Pi src/flush.ts: flushProgress calls readFlushProgress and throws the same InvalidResponseError as before. The local FlushProgress, nonNegativeInteger, scopeCorrelation, and the node:crypto import are removed. src/capture.ts keeps importing flushProgress from src/flush.ts.
  • Both plugins' tests still read tests/integration_conformance/cases.json and are unchanged.

Are there any user-facing changes?

No. Flush acknowledgement, error handling, and diagnostics are unchanged.

How was this change tested?

  • make openclaw-plugin-test: tests, type check, and build.

  • make pi-test: tests and type check.

  • make check, including scripts/generate_integration_lifecycle.py --check, and git diff --check.

  • uv run pytest tests/test_integration_lifecycle.py tests/test_integration_shared_files.py tests/test_ci_changes.py tests/test_integration_manifest.py.

  • No real host was run; the change does not alter behavior.

  • Self-review against REVIEW.md, plus an independent review pass. Fixed:

    • Module comment. It said the conformance cases exercise all three helpers. They exercise the flush response check; scopeCorrelation is covered by each plugin's diagnostics tests.
    • Generator comment. It said a copy keeps the path its plugin already imports, which is not true of a new module; it now says each copy sits at the path its plugin imports.

    Confirmed:

    Left as notes:

    • Wrappers. Each plugin keeps a short flushProgress that turns undefined into its own error. Passing an error into the shared module would make it depend on plugin error types.
    • CI routing. A change to integrations/lifecycle/ also runs the DSH, Cindy, and OpenCode suites, which do not ship this module. Splitting the path rule per file is not worth it yet.
    • Generator conflict with the prompt-privacy PR. The PR that generates the prompt-privacy rule also adds a TYPESCRIPT_COPIES entry above transport.ts. Whichever merges second keeps both entries in name order and reruns make integration-lifecycle.

AI usage statement

Claude Code (Claude Opus 5.5) wrote the change and this description, and ran the checks above.

…om one source

OpenClaw's src/lifecycle.ts and Pi's src/flush.ts each defined
nonNegativeInteger, the flush response check, and scopeCorrelation. The
checks and the correlation hash were the same; only the error each plugin
throws for an invalid flush response differed.

integrations/lifecycle/flush-progress.ts is now the source, and
scripts/generate_integration_lifecycle.py writes it to
src/flush-progress.ts in both plugins, so `make check` rejects a copy that
drifts. readFlushProgress returns undefined for a response that is not a
flush result. Each plugin's flushProgress keeps throwing its own error:
OpenClaw a plain Error with the same message, Pi InvalidResponseError for
/v1/memory/flush. Both plugins' tests still read
tests/integration_conformance/cases.json. Behavior does not change.

@hireview001 hireview001 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed d411ab4. No blocking findings. The shared helpers preserve flush acknowledgement validation, host-specific errors, and Scope correlation; the generated copies are included in both plugin packages. No database schema or public API changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants